export default {
  state: {
    token: "",
    userId: "",
    userAccount: "",
    username: "",
    isAdmin: false,
    phoneNumber: "",
    permissions: [],
    project: {
      id: "",
      name: ""
    },
    statusStep: "0",
    respId: "",
    activePage: "index",
    multiple: true // 是否是多个项目
  },
  mutations: {
    SETOKEN(state, data) {
      state.token = data;
    },
    SETUSERID(state, data) {
      state.userId = data;
    },
    SETUSERACCOUNT(state, data) {
      state.userAccount = data;
    },
    SETUSERNAME(state, data) {
      state.username = data;
    },
    SETISADMIN(state, data) {
      state.isAdmin = data;
    },
    SETPHONENUMBER(state, data) {
      state.phoneNumber = data;
    },
    SETPERMISSIONS(state, data) {
      state.permissions = data;
    },
    CHANGEPROJECT: (state, project) => {
      state.project = {
        id: project.id,
        name: project.name
      };
    },
    SETACTIVEPAGE(state, page) {
      state.activePage = page;
    },
    SETMULTIPLE(state, data) {
      state.multiple = data;
    }
  },
  actions: {
    setToken({ commit }, data) {
      commit("SETOKEN", data);
    },
    setUserId({ commit }, data) {
      commit("SETUSERID", data);
    },
    setUserAccount({ commit }, data) {
      commit("SETUSERACCOUNT", data);
    },
    setUserName({ commit }, data) {
      commit("SETUSERNAME", data);
    },
    setIsAdmin({ commit }, data) {
      commit("SETISADMIN", data);
    },
    setPhoneNumber({ commit }, data) {
      commit("SETPHONENUMBER", data);
    },
    setPermissions({ commit }, data) {
      commit("SETPERMISSIONS", data);
    },
    changeProject({ commit }, project) {
      commit("CHANGEPROJECT", project);
    },
    setActivePage({ commit }, page) {
      commit("SETACTIVEPAGE", page);
    },
    setMultiple({ commit }, data) {
      commit("SETMULTIPLE", data);
    }
  }
};
